﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class bb_修改车辆出入信息 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }

    }
    protected void BindData()    //绑定数据源
    {
        users tmp = new users();
        gvInsert.DataSource = tmp.GetALLUsers3().Tables[0].DefaultView;
        gvInsert.DataBind();
    }

    protected void gvInsert_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvInsert.PageIndex = e.NewPageIndex;
        BindData();//重新绑定数据

    }
    protected void gvInsert_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        gvInsert.EditIndex = -1;
        BindData();

    }
    protected void gvInsert_RowEditing(object sender, GridViewEditEventArgs e)
    {
        gvInsert.EditIndex = e.NewEditIndex;
        BindData();

    }
    protected void gvInsert_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {

        users us = new users();
        string id = gvInsert.DataKeys[e.RowIndex].Value.ToString().Trim();
        string name = ((TextBox)(gvInsert.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Trim();
        string sex = ((TextBox)(gvInsert.Rows[e.RowIndex].Cells[2].Controls[0])).Text.Trim();
        string phone = ((TextBox)(gvInsert.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim();
        string home = ((TextBox)(gvInsert.Rows[e.RowIndex].Cells[4].Controls[0])).Text.Trim();
        us.id = id;
        us.name = name;
        us.sex = sex;
        us.phone = phone;
        us.home = home;
        us.GenXin3(us);
        BindData();

    }
}